////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2017-2018 Qualcomm Technologies, Inc.
// All Rights Reserved.
// Confidential and Proprietary - Qualcomm Technologies, Inc.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// THIS IS AUTO-GENERATED CODE.  PLEASE DO NOT EDIT (File bug reports against tools).
///
/// Auto-generated by: ParameterParser V1.1.4
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @file  afdciafelements.cpp
/// @brief Auto-generated Chromatix parameter file
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include "afdciafelements.h"
#include "parametersetmanager.h"

AFDCIAFELEMENTS_NAMESPACE_BEGIN

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixDCIAFTypeClass::chromatixDCIAFTypeClass(
    const CHAR* name)
    : ParameterModule(name, MAJOR, MINOR, PATCH, 0, 0, 0, 0)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(monitorEnable);
    PARAMETER_INITIALIZE(monitorFrequency);
    PARAMETER_INITIALIZE(searchFrequency);
    PARAMETER_INITIALIZE(baselineMM);
    PARAMETER_INITIALIZE(auxDirection);
    PARAMETER_INITIALIZE(macroEstimateLimitCM);
    PARAMETER_INITIALIZE(alignmentCheckEnable);
    PARAMETER_INITIALIZE(jumpToStartLimit);
    PARAMETER_INITIALIZE(numNearSteps);
    PARAMETER_INITIALIZE(numFarSteps);
    PARAMETER_INITIALIZE(dciafStepSize);
    PARAMETER_INITIALIZE(motionDataUseEnable);
    PARAMETER_INITIALIZE(sceneChangeLensPositionThreshold);
    PARAMETER_INITIALIZE(panningStableLensPositionThreshold);
    PARAMETER_INITIALIZE(panningStableDurationMSBright);
    PARAMETER_INITIALIZE(panningStableDurationMSLow);
    PARAMETER_INITIALIZE(maxLowLightWaitMs);
    PARAMETER_INITIALIZE(maxNormalLightWaitMs);
    PARAMETER_INITIALIZE(jumpWithNoSkip);
    PARAMETER_INITIALIZE(skipframesBeforeFineSearch);
    PARAMETER_INITIALIZE(distanceThresholdMacroRegionInMM);
    PARAMETER_INITIALIZE(distanceThresholdNonMacroFactor);
    PARAMETER_INITIALIZE(lowLightThreshold);
    PARAMETER_INITIALIZE(useFineSearchExtension);
    PARAMETER_INITIALIZE(macroRegionThresholdInMM);
    PARAMETER_INITIALIZE(farRegionThresholdInMM);
    PARAMETER_INITIALIZE(normalLightFineSearchInfoCount);
    PARAMETER_INITIALIZE(normalLightFineSearchInfoID);
    PARAMETER_INITIALIZE(normalLightFineSearchInfo);
    PARAMETER_INITIALIZE(lowLightFineSearchInfoCount);
    PARAMETER_INITIALIZE(lowLightFineSearchInfoID);
    PARAMETER_INITIALIZE(lowLightFineSearchInfo);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixDCIAFTypeClass::chromatixDCIAFTypeClass(
    const CHAR* name,
    UINT32 modeId,
    UINT16 mode,
    UINT16 subMode,
    UINT32 group)
    : ParameterModule(name, MAJOR, MINOR, PATCH, modeId, mode, subMode, group)
{
    PARAMETER_INITIALIZE(SymbolTableID);
    PARAMETER_INITIALIZE(module_version);
    PARAMETER_INITIALIZE(parameter_version);
    PARAMETER_INITIALIZE(monitorEnable);
    PARAMETER_INITIALIZE(monitorFrequency);
    PARAMETER_INITIALIZE(searchFrequency);
    PARAMETER_INITIALIZE(baselineMM);
    PARAMETER_INITIALIZE(auxDirection);
    PARAMETER_INITIALIZE(macroEstimateLimitCM);
    PARAMETER_INITIALIZE(alignmentCheckEnable);
    PARAMETER_INITIALIZE(jumpToStartLimit);
    PARAMETER_INITIALIZE(numNearSteps);
    PARAMETER_INITIALIZE(numFarSteps);
    PARAMETER_INITIALIZE(dciafStepSize);
    PARAMETER_INITIALIZE(motionDataUseEnable);
    PARAMETER_INITIALIZE(sceneChangeLensPositionThreshold);
    PARAMETER_INITIALIZE(panningStableLensPositionThreshold);
    PARAMETER_INITIALIZE(panningStableDurationMSBright);
    PARAMETER_INITIALIZE(panningStableDurationMSLow);
    PARAMETER_INITIALIZE(maxLowLightWaitMs);
    PARAMETER_INITIALIZE(maxNormalLightWaitMs);
    PARAMETER_INITIALIZE(jumpWithNoSkip);
    PARAMETER_INITIALIZE(skipframesBeforeFineSearch);
    PARAMETER_INITIALIZE(distanceThresholdMacroRegionInMM);
    PARAMETER_INITIALIZE(distanceThresholdNonMacroFactor);
    PARAMETER_INITIALIZE(lowLightThreshold);
    PARAMETER_INITIALIZE(useFineSearchExtension);
    PARAMETER_INITIALIZE(macroRegionThresholdInMM);
    PARAMETER_INITIALIZE(farRegionThresholdInMM);
    PARAMETER_INITIALIZE(normalLightFineSearchInfo);
    PARAMETER_INITIALIZE(lowLightFineSearchInfo);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
chromatixDCIAFTypeClass::~chromatixDCIAFTypeClass()
{
    UnloadchromatixDCIAFType(this);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// GetName
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const CHAR* chromatixDCIAFTypeClass::GetName(
    const CHAR* type)
{
    const CHAR* name = type;
    CHAR temp[ParameterFileSymbolTableEntry::TYPE_LEN + 1];
    if (PARAMETER_STRCMP(type, ParameterFileSymbolTableEntry::GetType(temp, "chromatixDCIAF")) == 0)
    {
        name = "chromatixDCIAF";
    }
    return name;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixAFDCIAFFineSearchStepInfoType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixDCIAFTypeClass::LoadchromatixAFDCIAFFineSearchStepInfoType(
    ParameterFileSymbolTableEntry* entry,
    chromatixAFDCIAFFineSearchStepInfoType* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->stepSize);
    result = result && entry->ReadInt32(&structure->farSteps);
    result = result && entry->ReadInt32(&structure->nearSteps);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load chromatixDCIAFType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixDCIAFTypeClass::LoadchromatixDCIAFType(
    ParameterFileSymbolTableEntry* entry,
    chromatixDCIAFType* structure)
{
    BOOL result = TRUE;
    result = result && Loadmodule_versionStruct(entry, &structure->module_version);
    result = result && Loadparameter_versionStruct(entry, &structure->parameter_version);
    result = result && entry->ReadUInt32(&structure->monitorEnable);
    result = result && entry->ReadInt32(&structure->monitorFrequency);
    result = result && entry->ReadInt32(&structure->searchFrequency);
    result = result && entry->ReadFloat(&structure->baselineMM);
    structure->auxDirection = (chromatixAFCameraOrientationType)entry->ReadEnum(&result);
    result = result && entry->ReadFloat(&structure->macroEstimateLimitCM);
    result = result && entry->ReadUInt32(&structure->alignmentCheckEnable);
    result = result && entry->ReadInt32(&structure->jumpToStartLimit);
    result = result && entry->ReadInt32(&structure->numNearSteps);
    result = result && entry->ReadInt32(&structure->numFarSteps);
    result = result && entry->ReadInt32(&structure->dciafStepSize);
    result = result && entry->ReadUInt32(&structure->motionDataUseEnable);
    result = result && entry->ReadInt32(&structure->sceneChangeLensPositionThreshold);
    result = result && entry->ReadInt32(&structure->panningStableLensPositionThreshold);
    result = result && entry->ReadInt32(&structure->panningStableDurationMSBright);
    result = result && entry->ReadInt32(&structure->panningStableDurationMSLow);
    result = result && entry->ReadInt32(&structure->maxLowLightWaitMs);
    result = result && entry->ReadInt32(&structure->maxNormalLightWaitMs);
    result = result && entry->ReadInt32(&structure->jumpWithNoSkip);
    result = result && entry->ReadInt32(&structure->skipframesBeforeFineSearch);
    result = result && entry->ReadInt32(&structure->distanceThresholdMacroRegionInMM);
    result = result && entry->ReadInt32(&structure->distanceThresholdNonMacroFactor);
    result = result && entry->ReadInt32(&structure->lowLightThreshold);
    result = result && entry->ReadUInt32(&structure->useFineSearchExtension);
    result = result && entry->ReadInt32(&structure->macroRegionThresholdInMM);
    result = result && entry->ReadInt32(&structure->farRegionThresholdInMM);

    // Reading structure->normalLightFineSearchInfo from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->normalLightFineSearchInfoCount);
        structure->normalLightFineSearchInfoID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->normalLightFineSearchInfo   = PARAMETER_NEW chromatixAFDCIAFFineSearchStepInfoType[structure->normalLightFineSearchInfoCount];
        }
        if (!result || structure->normalLightFineSearchInfo == NULL)
        {
            structure->normalLightFineSearchInfoCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->normalLightFineSearchInfoCount; i++)
        {
            result = result && LoadchromatixAFDCIAFFineSearchStepInfoType(pointerEntry1, &structure->normalLightFineSearchInfo[i]);
        }
    }

    // Reading structure->lowLightFineSearchInfo from the symbol table
    {
        result = result && entry->ReadUInt32(&structure->lowLightFineSearchInfoCount);
        structure->lowLightFineSearchInfoID = entry->ID;
        ParameterFileSymbolTableEntry* pointerEntry1 = entry->Table->ReadPointerEntry(entry);
        result = result && pointerEntry1 != NULL;
        if (result)
        {
            structure->lowLightFineSearchInfo   = PARAMETER_NEW chromatixAFDCIAFFineSearchStepInfoType[structure->lowLightFineSearchInfoCount];
        }
        if (!result || structure->lowLightFineSearchInfo == NULL)
        {
            structure->lowLightFineSearchInfoCount = 0;
        }
        for (UINT32 i = 0; result && i < structure->lowLightFineSearchInfoCount; i++)
        {
            result = result && LoadchromatixAFDCIAFFineSearchStepInfoType(pointerEntry1, &structure->lowLightFineSearchInfo[i]);
        }
    }

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load module_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixDCIAFTypeClass::Loadmodule_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixDCIAFType::module_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Load parameter_versionStruct
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
BOOL chromatixDCIAFTypeClass::Loadparameter_versionStruct(
    ParameterFileSymbolTableEntry* entry,
    chromatixDCIAFType::parameter_versionStruct* structure)
{
    BOOL result = TRUE;
    result = result && entry->ReadInt32(&structure->major_revision);
    result = result && entry->ReadInt32(&structure->minor_revision);

    return result;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Unload chromatixDCIAFType
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void chromatixDCIAFTypeClass::UnloadchromatixDCIAFType(
    chromatixDCIAFType* structure)
{
    PARAMETER_DELETE[] structure->normalLightFineSearchInfo;
    PARAMETER_DELETE[] structure->lowLightFineSearchInfo;
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Parse symbol table entry, and return a new object
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ParameterModule* chromatixDCIAFTypeClass::Parse(
    ParameterSetManager* manager,
    ParameterFileSymbolTableEntry* entry) const
{
    chromatixDCIAFTypeClass* cls = NULL;

    if (PARAMETER_STRCMP(Type, entry->Type) == 0 && Major == entry->Major &&
        Minor == entry->Minor && Patch == entry->Patch)
    {
        cls = PARAMETER_NEW chromatixDCIAFTypeClass(GetName(entry->Type), 
            entry->ModeId, entry->Mode, entry->SubMode, entry->Group);
        if (cls != NULL)
        {
            BOOL result = TRUE;

            cls->SymbolTableID = entry->ID;
            cls->ID            = entry->ID;

            result = result && LoadchromatixDCIAFType(entry, cls);

            if (!result)
            {
                PARAMETER_DELETE cls;
                cls = NULL;
            }
        }
    }
    return (ParameterModule*)cls;
}


AFDCIAFELEMENTS_NAMESPACE_END
